package com.fanfanwang.ffw.app.ui.my;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.toolbox.NetworkImageView;
import com.fanfanwang.ffw.app.AppManager;
import com.fanfanwang.ffw.app.base.BaseActivity;
import com.fanfanwang.ffw.app.common.StringUtils;
import com.fanfanwang.ffw.app.common.ToastAlone;
import com.fanfanwang.ffw.app.tenant.R;
import com.fanfanwang.ffw.app.ui.HomeActivity;
import com.fanfanwang.ffw.app.widget.CommonTitleBar;

/**
 * 修改个人信息
 * @author Administrator
 *
 */
public class MyUpdateInfoAct extends BaseActivity {

	private CommonTitleBar commonTitleBar;
	private Activity mAct;
	private Intent mIntent;
	private RelativeLayout rl_sex;
	private TextView tv_sex_value;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		initView();
		AppManager.getAppManager().addActivity(this);
		initData();
		setListener();
	}

	@Override
	public void initView() {
		// TODO Auto-generated method stub
		setContentView(R.layout.activity_my_update_info);
		mAct = this;
		commonTitleBar = (CommonTitleBar) findViewById(R.id.common_titlebar);

		rl_sex=(RelativeLayout)findViewById(R.id.rl_sex);
		tv_sex_value=(TextView)findViewById(R.id.tv_sex_value);
	}

	@Override
	public void setListener() {
		rl_sex.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				int i=0;
				String sex=tv_sex_value.getText().toString();
				if(!TextUtils.isEmpty(sex)){
					if(sex.equals(getString(R.string.male))){
						i=0;
					}else{
						i=1;
					}
				}
				showSingleDialog(i);

			}
		});
		commonTitleBar.setLeftView(getString(R.string.cancel), new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		commonTitleBar.setRightView(getString(R.string.confirm), new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		commonTitleBar.setToolBarReturnOnclickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}
	public void showSingleDialog(int i){

		Builder builder = new AlertDialog.Builder(this);  
		Dialog dialog;
		builder.setTitle("选择性别");
		//		builder.setSingleChoiceItems(R.array.my_list_sex, 0,new OnCLick);
		builder.setSingleChoiceItems(R.array.my_list_sex,i,new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				switch(which)
				{
				case 0:
					tv_sex_value.setText(getString(R.string.male));
					dialog.dismiss();
					break;
				case 1:
					tv_sex_value.setText(getString(R.string.female));
					dialog.dismiss();
					break;

				}
			}
		} );
		dialog=builder.show();
	}

	@Override
	public void initData() {
		// TODO Auto-generated method stub
		commonTitleBar.setCenterText(getString(R.string.edit_my_info));
		//		commonTitleBar.setReturnVisible();
	}

}
